package com.baizhi.ncc.controller;

import com.baizhi.ncc.entity.Admin;
import com.baizhi.ncc.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

@Controller
@CrossOrigin
@RequestMapping("admin")
public class AdminController {
    @Autowired
    private AdminService adminService;
    //获取验证码
    @ResponseBody
    @RequestMapping("getImageCodes")
    Map<String,String> getImageCodes()throws IOException {
        return adminService.getImageCodes();
    }
    //登录
    @ResponseBody
    @RequestMapping(value = "login",method = RequestMethod.POST)
    Map<String,String> login(@RequestBody Admin admin, String token){
        return adminService.login(admin,token);
    }
    //获取登录用户信息
    @ResponseBody
    @RequestMapping("getUserInfo")
    Admin getUserInfo(String token){
        return adminService.getUserInfo(token);
    }
    //退出
    @ResponseBody
    @RequestMapping("logout")
    void logout(String token){
         adminService.logout(token);
    }
}
